<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>文档转换后内容</title>
    <!-- 引入 D3.js 库 -->
    <script src="https://d3js.org/d3.v7.min.js"></script>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 20px;
        }

        h1,
        h2,
        h3 {
            color: #333;
        }

        table {
            border-collapse: collapse;
            width: 100%;
            margin-bottom: 20px;
        }

        th,
        td {
            border: 1px solid #ddd;
            padding: 8px;
            text-align: left;
        }

        th {
            background-color: #f2f2f2;
        }

        .chart-container {
            margin-bottom: 20px;
            text-align: center;
        }
    </style>
</head>

<body>
    <h1>文档转换后内容</h1>

    <h3>一、投标报价总体情况</h3>
    <p>本项目为长春华翔车顶二层钢平台工程，投标总价为 490499.99 元，由建筑工程、通风工程、电气设备安装工程三部分组成。</p>
    <table id="table1">
        <thead>
            <tr>
                <th>单位工程名称</th>
                <th>金额（元）</th>
                <th>暂估价（元）</th>
                <th>安全文明施工费（元）</th>
                <th>规费（元）</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>建筑工程</td>
                <td>426439.18</td>
                <td>0</td>
                <td>15238.74</td>
                <td>-</td>
            </tr>
            <tr>
                <td>通风工程</td>
                <td>12454.45</td>
                <td>0</td>
                <td>247.38</td>
                <td>-</td>
            </tr>
            <tr>
                <td>电气设备安装工程</td>
                <td>51606.36</td>
                <td>0</td>
                <td>733.96</td>
                <td>-</td>
            </tr>
            <tr>
                <td>合计</td>
                <td>490499.99</td>
                <td>0</td>
                <td>16220.08</td>
                <td>-</td>
            </tr>
        </tbody>
    </table>
    <div class="chart-container" id="chart1"></div>

    <h3>二、各单位工程费用分析</h3>

    <h4>1. 建筑工程</h4>
    <p>
        <strong>费用构成</strong>：建筑工程投标报价 426439.18 元，主要由分部分项及单价措施费 375989.87 元、总价措施费
        15238.74 元、税金 35210.57 元组成。
    </p>
    <p>
        <strong>分部分项费用占比</strong>：金属结构工程占比最大，金额为 175489.58 元，占分部分项及单价措施费的 46.67%；其次为拆除工程、门窗工程等。
    </p>
    <table id="table2">
        <thead>
            <tr>
                <th>序号</th>
                <th>汇总内容</th>
                <th>金额（元）</th>
                <th>占比（%）</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>1</td>
                <td>分部分项及单价措施费</td>
                <td>375989.87</td>
                <td>88.17</td>
            </tr>
            <tr>
                <td>1.1</td>
                <td>拆除工程</td>
                <td>35537.69</td>
                <td>8.33</td>
            </tr>
            <tr>
                <td>1.2</td>
                <td>混凝土及钢筋混凝土工程</td>
                <td>31887.82</td>
                <td>7.48</td>
            </tr>
            <tr>
                <td>1.3</td>
                <td>金属结构工程</td>
                <td>175489.58</td>
                <td>41.15</td>
            </tr>
            <tr>
                <td>1.4</td>
                <td>门窗工程</td>
                <td>34347.58</td>
                <td>8.05</td>
            </tr>
            <tr>
                <td>1.5</td>
                <td>楼地面工程</td>
                <td>15395.7</td>
                <td>3.61</td>
            </tr>
            <tr>
                <td>1.6</td>
                <td>墙面</td>
                <td>35437.71</td>
                <td>8.31</td>
            </tr>
            <tr>
                <td>1.7</td>
                <td>天棚</td>
                <td>25800</td>
                <td>6.05</td>
            </tr>
            <tr>
                <td>1.8</td>
                <td>其他</td>
                <td>10307.98</td>
                <td>2.42</td>
            </tr>
            <tr>
                <td>1.9</td>
                <td>单价措施费</td>
                <td>11785.81</td>
                <td>2.76</td>
            </tr>
            <tr>
                <td>2</td>
                <td>总价措施费</td>
                <td>15238.74</td>
                <td>3.57</td>
            </tr>
            <tr>
                <td>2.1</td>
                <td>其中:安全文明施工费</td>
                <td>15238.74</td>
                <td>3.57</td>
            </tr>
            <tr>
                <td>3</td>
                <td>其他项目</td>
                <td>0</td>
                <td>0</td>
            </tr>
            <tr>
                <td>4</td>
                <td>税金</td>
                <td>35210.57</td>
                <td>8.26</td>
            </tr>
            <tr>
                <td>投标报价合计</td>
                <td>426439.18</td>
                <td>100</td>
                <td></td>
            </tr>
        </tbody>
    </table>
    <div class="chart-container" id="chart2"></div>

    <h4>2. 通风工程</h4>
    <p>
        <strong>费用构成</strong>：通风工程投标报价 12454.45 元，由分部分项及单价措施费 11178.72 元、总价措施费 247.38
        元、税金 1028.35 元组成。
    </p>
    <p>
        <strong>分部分项费用占比</strong>：通风工程中，碳钢通风管道费用 3006.67 元，占分部分项及单价措施费的 26.89%，轴流通风机费用
        2720.13 元，占比 24.33% 。
    </p>
    <table id="table3">
        <thead>
            <tr>
                <th>序号</th>
                <th>汇总内容</th>
                <th>金额（元）</th>
                <th>占比（%）</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>1</td>
                <td>分部分项及单价措施费</td>
                <td>11178.72</td>
                <td>89.75</td>
            </tr>
            <tr>
                <td>1.1</td>
                <td>通风工程</td>
                <td>10953.83</td>
                <td>87.95</td>
            </tr>
            <tr>
                <td>1.2</td>
                <td>单价措施费</td>
                <td>224.89</td>
                <td>1.81</td>
            </tr>
            <tr>
                <td>2</td>
                <td>总价措施费</td>
                <td>247.38</td>
                <td>1.99</td>
            </tr>
            <tr>
                <td>2.1</td>
                <td>其中:安全文明施工费</td>
                <td>247.38</td>
                <td>1.99</td>
            </tr>
            <tr>
                <td>3</td>
                <td>其他项目</td>
                <td>0</td>
                <td>0</td>
            </tr>
            <tr>
                <td>4</td>
                <td>税金</td>
                <td>1028.35</td>
                <td>8.26</td>
            </tr>
            <tr>
                <td>投标报价合计</td>
                <td>12454.45</td>
                <td>100</td>
                <td></td>
            </tr>
        </tbody>
    </table>
    <div class="chart-container" id="chart3"></div>

    <h4>3. 电气设备安装工程</h4>
    <p>
        <strong>费用构成</strong>：电气设备安装工程投标报价 51606.36 元，由分部分项及单价措施费 46611.32 元、总价措施费
        733.96 元、税金 4261.08 元组成。
    </p>
    <p>
        <strong>分部分项费用占比</strong>：强电系统费用 39085.93 元，占分部分项及单价措施费的 83.85%，弱电桥架及配管费用
        6858.16 元，占比 14.71% 。
    </p>
    <table id="table4">
        <thead>
            <tr>
                <th>序号</th>
                <th>汇总内容</th>
                <th>金额（元）</th>
                <th>占比（%）</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>1</td>
                <td>分部分项及单价措施费</td>
                <td>46611.32</td>
                <td>90.32</td>
            </tr>
            <tr>
                <td>1.1</td>
                <td>强电系统</td>
                <td>39085.93</td>
                <td>75.74</td>
            </tr>
            <tr>
                <td>1.2</td>
                <td>弱电桥架及配管</td>
                <td>6858.16</td>
                <td>13.29</td>
            </tr>
            <tr>
                <td>1.3</td>
                <td>单价措施费</td>
                <td>667.23</td>
                <td>1.29</td>
            </tr>
            <tr>
                <td>2</td>
                <td>总价措施费</td>
                <td>733.96</td>
                <td>1.42</td>
            </tr>
            <tr>
                <td>2.1</td>
                <td>其中:安全文明施工费</td>
                <td>733.96</td>
                <td>1.42</td>
            </tr>
            <tr>
                <td>3</td>
                <td>其他项目</td>
                <td>0</td>
                <td>0</td>
            </tr>
            <tr>
                <td>4</td>
                <td>税金</td>
                <td>4261.08</td>
                <td>8.26</td>
            </tr>
            <tr>
                <td>投标报价合计</td>
                <td>51606.36</td>
                <td>100</td>
                <td></td>
            </tr>
        </tbody>
    </table>
    <div class="chart-container" id="chart4"></div>

    <h3>三、价格合理性分析</h3>
    <p>由于缺乏同类项目参考数据，无法直接判断价格绝对合理性。但从各单位工程费用构成来看，各项费用设置基本遵循常规的工程计价规则，安全文明施工费等措施费按规定计取。需进一步结合市场行情、当地定额标准等进行深入分析价格合理性。</p>

    <script>
        // 绘制第一个表格的饼图
        function drawPieChart(tableId, chartId) {
            const table = document.getElementById(tableId);
            const data = [];
            const rows = table.rows;
            for (let i = 1; i < rows.length - 1; i++) {
                const cells = rows[i].cells;
                const label = cells[0].textContent;
                const value = parseFloat(cells[1].textContent);
                data.push({ label, value });
            }

            const width = 400;
            const height = 400;
            const radius = Math.min(width, height) / 2;

            const svg = d3.select(`#${chartId}`)
               .append("svg")
               .attr("width", width)
               .attr("height", height)
               .append("g")
               .attr("transform", `translate(${width / 2},${height / 2})`);

            const color = d3.scaleOrdinal(d3.schemeCategory10);

            const pie = d3.pie()
               .value(d => d.value);

            const arc = d3.arc()
               .innerRadius(0)
               .outerRadius(radius);

            const arcs = svg.selectAll(".arc")
               .data(pie(data))
               .enter()
               .append("g")
               .attr("class", "arc");

            arcs.append("path")
               .attr("d", arc)
               .attr("fill", d => color(d.data.label));

            arcs.append("text")
               .attr("transform", d => `translate(${arc.centroid(d)})`)
               .attr("text-anchor", "middle")
               .text(d => d.data.label);
        }

        // 绘制第二个、第三个和第四个表格的柱状图
        function drawBarChart(tableId, chartId) {
            const table = document.getElementById(tableId);
            const data = [];
            const rows = table.rows;
            for (let i = 1; i < rows.length - 1; i++) {
                const cells = rows[i].cells;
                const label = cells[1].textContent;
                const value = parseFloat(cells[2].textContent);
                data.push({ label, value });
            }

            const width = 600;
            const height = 400;
            const margin = { top: 20, right: 20, bottom: 30, left: 40 };

            const svg = d3.select(`#${chartId}`)
               .append("svg")
               .attr("width", width + margin.left + margin.right)
               .attr("height", height + margin.top + margin.bottom)
               .append("g")
               .attr("transform", `translate(${margin.left},${margin.top})`);

            const x = d3.scaleBand()
               .range([0, width])
               .padding(0.1);

            const y = d3.scaleLinear()
               .range([height, 0]);

            x.domain(data.map(d => d.label));
            y.domain([0, d3.max(data, d => d.value)]);

            svg.selectAll(".bar")
               .data(data)
               .enter().append("rect")
               .attr("class", "bar")
               .attr("x", d => x(d.label))
               .attr("width", x.bandwidth())
               .attr("y", d => y(d.value))
               .attr("height", d => height - y(d.value));

            svg.append("g")
               .attr("transform", `translate(0,${height})`)
               .call(d3.axisBottom(x));

            svg.append("g")
               .call(d3.axisLeft(y));
        }

        drawPieChart("table1", "chart1");
        drawBarChart("table2", "chart2");
        drawBarChart("table3", "chart3");
        drawBarChart("table4", "chart4");
    </script>
</body>

</html>